//= require jquery.dataTables.min

var stocksTable
$(document).ready(function(){


  $('#stock_purchase_quantity').change(function(){
    $('#stock_quantity').val($(this).val());
  });

  stocksTable = $('#stocks').dataTable( {
          "bPaginate": false,
          "bLengthChange": false,
          "bFilter": true,
          "bSort": false,
          "bInfo": false,
          "bAutoWidth": false
        });
  add_click_event_to_stock();
 });

function add_click_event_to_stock(){
  $("#stocks tr").click(function(){
  var $tr = $(this);
    createSold($tr);
    stocksTable.fnDeleteRow($(this).index());
  });
}

